{% extends "base_generic.html" %}

{% block title %}My Profile - Local Library{% endblock %}

{% block content %}
<div class="row">
  <div class="col-md-8">
    <div class="card">
      <div class="card-header">
        <h4><i class="bi bi-person-gear"></i> My Profile</h4>
      </div>
      <div class="card-body">
        <form method="post">
          {% csrf_token %}
          
          <div class="row mb-3">
            <div class="col-md-6">
              <label class="form-label">Username</label>
              <input type="text" class="form-control" value="{{ user.username }}" readonly>
            </div>
            <div class="col-md-6">
              <label class="form-label">Email</label>
              <input type="email" class="form-control" value="{{ user.email }}" readonly>
            </div>
          </div>
          
          <div class="row mb-3">
            <div class="col-md-6">
              <label class="form-label">First Name</label>
              <input type="text" class="form-control" value="{{ user.first_name }}" readonly>
            </div>
            <div class="col-md-6">
              <label class="form-label">Last Name</label>
              <input type="text" class="form-control" value="{{ user.last_name }}" readonly>
            </div>
          </div>
          
          <div class="mb-3">
            <label for="{{ form.phone_number.id_for_label }}" class="form-label">Phone Number</label>
            {{ form.phone_number }}
            {% if form.phone_number.errors %}
              <div class="text-danger">{{ form.phone_number.errors }}</div>
            {% endif %}
          </div>
          
          <div class="mb-3">
            <label for="{{ form.address.id_for_label }}" class="form-label">Address</label>
            {{ form.address }}
            {% if form.address.errors %}
              <div class="text-danger">{{ form.address.errors }}</div>
            {% endif %}
          </div>
          
          <div class="mb-3">
            <label for="{{ form.date_of_birth.id_for_label }}" class="form-label">Date of Birth</label>
            {{ form.date_of_birth }}
            {% if form.date_of_birth.errors %}
              <div class="text-danger">{{ form.date_of_birth.errors }}</div>
            {% endif %}
          </div>
          
          <button type="submit" class="btn btn-primary">
            <i class="bi bi-save"></i> Update Profile
          </button>
        </form>
      </div>
    </div>
  </div>
  
  <div class="col-md-4">
    <div class="card">
      <div class="card-header">
        <h5><i class="bi bi-info-circle"></i> Account Info</h5>
      </div>
      <div class="card-body">
        <p><strong>Member Since:</strong><br>{{ user.date_joined|date:"F j, Y" }}</p>
        <p><strong>Last Login:</strong><br>{{ user.last_login|date:"F j, Y g:i A" }}</p>
        <hr>
        <div class="d-grid gap-2">
          <a href="{% url 'password_change' %}" class="btn btn-outline-primary">
            <i class="bi bi-key"></i> Change Password
          </a>
          <a href="{% url 'my-borrowed' %}" class="btn btn-outline-success">
            <i class="bi bi-bookmark"></i> My Borrowed Books
          </a>
        </div>
      </div>
    </div>
  </div>
</div>
{% endblock %} 